home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / console / trc.c < prev   
C/C++ Source or Header  |  1997-07-22  |  3KB  |  162 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: trc.c,v 1.5 1997/07/09 13:21:11 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33. /*
  34.  * trc.c
  35.  *
  36.  * Tracer Library Interface Routines
  37.  *
  38.  */
  39.  
  40.  
  41. /* Tracer Library External Header */
  42.  
  43. #include <stdio.h>
  44. #ifndef WIN32
  45. #include <sys/time.h>
  46. #else
  47. #include <sys/timeb.h>
  48. #include <time.h>
  49. #endif
  50.  
  51. #include <pvm3.h>
  52. #include <pvmtev.h>
  53.  
  54. #include "job.h"
  55.  
  56. extern    int            mytid;        /* from cons.c */
  57.  
  58. extern    struct job    *joblist;    /* from cons.c */
  59.  
  60.  
  61. /* Set Up Tracer Library */
  62.  
  63. int
  64. trc_init()
  65. {
  66.     /* Initialize Tracer */
  67.  
  68.     trc_tracer_init();
  69.  
  70.     /* Set Tracer Globals */
  71.  
  72.     TRC_HOST_ADD_NOTIFY_CODE = 1;
  73.     TRC_HOST_DEL_NOTIFY_CODE = 2;
  74.  
  75.     TRC_VERSION = trc_copy_str( pvm_version() );
  76.  
  77.     TRC_NAME = "Console";
  78.  
  79.     TRC_TID = mytid;
  80.  
  81.     /* Check Hosts */
  82.  
  83.     trc_initialize_hosts( (TRC_ID) NULL );
  84.  
  85.     return( 0 );
  86. }
  87.  
  88.  
  89. struct job *get_job_trcid( ID )
  90. TRC_ID ID;
  91. {
  92.     struct job *jp;
  93.  
  94.     jp = joblist->j_link;
  95.  
  96.     while ( jp != joblist )
  97.     {
  98.         if ( jp->j_trcid == ID )
  99.             return( jp );
  100.  
  101.         jp = jp->j_link;
  102.     }
  103.  
  104.     fprintf( stderr, "Warning:  Matching Job Trace ID Not Found\n" );
  105.  
  106.     return( (struct job *) NULL );
  107. }
  108.  
  109.  
  110. /* Tracer Stub Routines - Called by library... */
  111.  
  112.  
  113. /* Status Message Handler */
  114.  
  115. void
  116. status_msg( ID, msg )
  117. TRC_ID ID;
  118. char *msg;
  119. {
  120.     struct job *jp;
  121.  
  122.     /* Find Corresponding Job */
  123.  
  124.     jp = get_job_trcid( ID );
  125.  
  126.     if ( jp != NULL )
  127.         fprintf( stderr, "[%d] libpvmtrc: %s\n", jp->j_jid, msg );
  128. }
  129.  
  130.  
  131. /* Trace Event Line Header */
  132.  
  133. void
  134. event_dump_hdr( ID, tid )
  135. TRC_ID ID;
  136. int tid;
  137. {
  138.     struct job *jp;
  139.  
  140.     jp = get_job_trcid( ID );
  141.  
  142.     if ( jp != NULL )
  143.         fprintf( ID->trace_out, "[T%d:t%x] ", jp->j_jid, tid );
  144. }
  145.  
  146.  
  147. /* Task Output Line Header */
  148.  
  149. void
  150. output_dump_hdr( ID, tid )
  151. TRC_ID ID;
  152. int tid;
  153. {
  154.     struct job *jp;
  155.  
  156.     jp = get_job_trcid( ID );
  157.  
  158.     if ( jp != NULL )
  159.         fprintf( ID->output_fp, "[%d:t%x] ", jp->j_jid, tid );
  160. }
  161.  
  162.